\( \require{newcommand} \)
\( \newcommand{\diff}[2]{\frac{d{#1}}{d{#2}}} \)
\( \newcommand{\pdiff}[2]{\partial_{#2}{#1}} \)

====== Diffusion ======

It is well known that diffusion will result from many small, random steps.  But what if the random walk depends on the local environment?  For example, what if individuals tend to move more in crowded/sparse local conditions?  How would that change the spatiotemporal distribution?

====== Conditions ======

To explore the possibilities I want to keep things as simple as possible.  Let's assume:
  - individuals are never created or destroyed,
  - there are only two types of individuals -- $M$ and $S$ -- that differ only in their tendency to move,
  - individuals switch between the two types in response to only their local environment,
  - individuals switch either spontaneously or in response to an interaction with a single neighbour, and
  - one of the types, $S$, is stationary.

====== Nonspatial ======

It may seem odd to consider a nonspatial model when exploring diffusion but the point here is just to look at the population dynamics of the two types in a well-mixed environment.  What kinds of reactions can we employ?  What results should we expect?  Here I will build a few separate models and look at their dynamics, especially the stable equilibria in the large population limit (mean field).




===== Model 1: Neighbor avoiding =====

Interaction with other individuals locally promotes movement.  Moving individuals relax to stationary.
\[
\begin{array}{rcl}
  S + S & \xrightarrow{\sigma} & M + S \\
  S + M & \xrightarrow{\sigma} & M + M \\
  M     & \xrightarrow{\rho} & S.
\end{array}
\]

Since the population is conserved, $n=s+m$, the dynamics reduce to a single equation,
The dynamics of a large, well-mixed population are then
\[
  \diff{m}{t} = \sigma s (s+m) - \rho m = \sigma (n-m) n - \rho m. 
\]
The population will equilibrate with a frequency of "movers" 	
\[
  \frac{m}{n} = \frac{\sigma n}{\sigma n + \rho}
\]
which varies from zero in the low-density limit, $n\rightarrow 0$, to one in the high-density limit, $n\rightarrow \infty$.  The midpoint ($m/n=1/2$) occurs when $n=\rho/\sigma$.




===== Model 2: Neighbour seeking =====

Here, individuals' natural tendency is to move.  Interaction with other individuals locally promotes stationarity.  Stationary individuals relax to moving.
\[
\begin{array}{rcl}
  M + M & \xrightarrow{\sigma} & S + M \\
  M + S & \xrightarrow{\sigma} & S + S \\
  S     & \xrightarrow{\rho} & M.
\end{array}
\]

By symmetry with Model 1 we see immediately that the population will equilibrate with a frequency of "stationaries"
\[
  \frac{s}{n} = \frac{\sigma n}{\sigma n + \rho}
\]
which varies from zero in the low-density limit, $n\rightarrow 0$, to one in the high-density limit, $n\rightarrow \infty$.  The midpoint ($s/n=1/2$) occurs when $n=\rho/\sigma$.




===== Model 3: Hole avoiding =====

Instead of being stimulated by interactions with neighbours we could think of individuals as interacting with absent neighbours, or "holes".  We then need to know the density of holes ($H$): let's say the carrying capacity (density) is $k\geq n$ and the hole density is $h=k-n$.

Hole avoiding behaviour could be expressed as
\[
\begin{array}{rcl}
  S + H & \xrightarrow{\sigma} & M + H \\
  M     & \xrightarrow{\rho} & S.
\end{array}
\]

The density of movers follows
\[
  \diff{m}{t} = \sigma s h - \rho m = \sigma (n-m)(k-n) - \rho m. 
\]
which equilibrates at
\[
  \frac{m}{n} = \frac{\sigma (k-n)}{\sigma (k-n) + \rho}.
\]
As $n\rightarrow k$ the frequency of movers approaches zero and it approaches a maximum of $\sigma k / (\sigma k + \rho)$ as $n \rightarrow 0$.




===== Model 4: Hole seeking =====

In this scenario individuals spontaneously rise to the moving state and lower to the stationary state by interactions with holes:
\[
\begin{array}{rcl}
  M + H & \xrightarrow{\sigma} & S + H \\
  S     & \xrightarrow{\rho} & M.
\end{array}
\]
By symmetry with Model 3 we see the equilibrium frequency of stationaries is
\[
  \frac{s}{n} = \frac{\sigma (k-n)}{\sigma (k-n) + \rho}.
\]





===== Supermodels =====

We can also merge models involving the same species to create new "supermodels".  

==== Neighbour supermodel ====

In the neighbour supermodel we merge both the neighbour models, involving just $S$ and $M$ types. We add subscripts to the rate constants to indicate their model of origin.
\[
\begin{array}{rcl}
  S + S & \xrightarrow{\sigma_1} & M + S \\
  S + M & \xrightarrow{\sigma_1} & M + M \\
  M     & \xrightarrow{\rho_1}   & S     \\
  M + M & \xrightarrow{\sigma_2} & S + M \\
  M + S & \xrightarrow{\sigma_2} & S + S \\
  S     & \xrightarrow{\rho_2}   & M.
\end{array}
\]

The nonspatial dynamics follow
\[
\begin{array}{rcl}
  \diff{m}{t} & = & \sigma_1 s (s+m) - \rho_1 m - \sigma_2 m (s+m) + \rho_2 s \\
              & = & (\sigma_1 (n-m) - \sigma_2 m) n - \rho_1 m + \rho_2 (n-m) \\
              & = & -(\sigma_1 n + \sigma_2 n + \rho_1 + \rho_2) m + (\sigma_1 n + \rho_2) n
\end{array}
\]
and the equilibrium frequency is
\[
  \frac{m}{n} = \frac{\sigma_1 n + \rho_2}{(\sigma_1 + \sigma_2) n + \rho_1 + \rho_2}.
\]




==== Hole supermodel ====

Likewise, we can merge the two hole-based models into
\[
\begin{array}{rcl}
  S + H & \xrightarrow{\sigma_3} & M + H \\
  M     & \xrightarrow{\rho_3}   & S     \\
  M + H & \xrightarrow{\sigma_4} & S + H \\
  S     & \xrightarrow{\rho_4}   & M
\end{array}
\]
which behaves as
\[
\begin{array}{rcl}
  \diff{m}{t} & = & \sigma_3 s h - \rho_3 m - \sigma_4 m h + \rho_4 s \\
              & = & \sigma_3 (n-m)(k-n) - \rho_3 m - \sigma_4 m (k-n) + \rho_4 (n-m) \\
              & = & \sigma_3 (n k - m k - n^2 + m n) - \rho_3 m - \sigma_4 m (k-n) + \rho_4 (n-m) \\
              & = & -((\sigma_3 + \sigma_4)(k-n) + \rho_3 + \rho_4) m + (\sigma_3 (k-n) + \rho_4) n,
\end{array}
\]
since $s+m=n$ and $n+h=k$.
Hence, the equilibrium frequency is
\[
  \frac{m}{n} = \frac{\sigma_3 (k-n) + \rho_4}{(\sigma_3 + \sigma_4)(k-n) + \rho_3 + \rho_4}.
\]





===== Equivalence? =====

Are these two approaches (neighbours versus holes) equivalent?  Will they exhibit the same dynamics?  If so then we should find a mapping from one approach to the other.  Two counterexamples show that there cannot be a perfect equivalence between neighbour seeking/avoiding and hole avoiding/seeking:
  - If there is a single individual in the neighbour seeking/avoiding models it cannot be stimulated to mobility/stationarity by a neighbour.  But holes would be plentiful in this limit so transitions in both directions could still occur in the hole avoiding/seeking models.
  - If there are no holes then individuals cannot be stimulated in the hole models.  But neighbours would be plentiful so both transitions would occur in the neighbour models.

Nevertheless, there may be a parameter-region where these models are roughly equivalent to each other.  For clarity let's subscript the rate constants with $n$ (neighbours) or $h$ (holes).  The equilibrium frequency of mobile types in each model is
|           ^                    Neighbour                    ^                        Hole                         ^
^  Avoiding | $$m/n=\frac{\sigma_n n}{\sigma_n n + \rho_n}$$  | $$m/n=\frac{\sigma_h(k-n)}{\sigma_h(k-n)+\rho_h}$$  |
^   Seeking | $$m/n=\frac{\rho_n}{\sigma_n n + \rho_n}$$      | $$m/n=\frac{\rho_h}{\sigma_h(k-n) + \rho_h}$$       |



Let's assume we're dealing with [[wp>elementary reaction|elementary reactions]] so the rate constants are independent of the population density or composition.  Then we find correspondence between these models
  * neighbour avoiding ⇔ hole seeking
  * neighbour seeking ⇔ hole avoiding
when
\[
  \frac{\rho_n \rho_h}{\sigma_n \sigma_h} = \text{constant} = n (k-n).
\]
Clearly, this condition is not generally true.  But the function $f(n)=n (k-n)$ is a parabola that is roughly constant at its maximum, when $n=k/2$.  The parabola takes on the right value when the carrying capacity $k$ is tuned to satisfy $n(k-n) \approx (k/2)^2 \approx \frac{\rho_n \rho_h}{\sigma_n \sigma_h}$, or
\[
  k \approx 2 \sqrt{\frac{\rho_n \rho_h}{\sigma_n \sigma_h}}.
\]
If we choose the hole model to have the same rate constants as the neighbour model ($\rho_h=\rho_n\equiv \rho$, & $\sigma_h=\sigma_n\equiv \sigma$) then the conditions for rough equivalence are $k\approx 2n$ and $n \approx \rho/\sigma$.  Under these conditions all four models have equilibrium frequencies $m/n=1/2$.




==== Supermodel equivalence ====

The equivalence criterion is easy to see in the supermodels.  The dynamics of the two follow
\[
\begin{array}{llrll}
  \left. \diff{m}{t} \right|_\text{neighbour} & = -((\sigma_1 + \sigma_2) n    & + \rho_1 + \rho_2) m & + (\sigma_1 n     & + \rho_2) n \\
  \left. \diff{m}{t} \right|_\text{hole}      & = -((\sigma_3 + \sigma_4)(k-n) & + \rho_3 + \rho_4) m & + (\sigma_3 (k-n) & + \rho_4) n,
\end{array}
\]
which suggests we need at least $n\approx k-n$, or $n\approx k/2$.  Then the mapping is simply
\[
\begin{array}{rcl}
  \sigma_{1,2} & \rightarrow & \sigma_{3,4}\\
  \rho_{1,2}   & \rightarrow & \rho_{3,4}.
\end{array}
\]
	


====== One dimension ======

===== Neighbour models =====

Let's consider an infinite one-dimensional strip of patches indexed as $\cdots, i-2, i-1, i, i+1, i+2, \cdots$.  Each patch contains individuals of type $S$ and $M$; patch $i$ has local densities $s_i, m_i$, and $n_i = s_i + m_i$.  Besides the local processes $M$-types also jump between patches at rate $\lambda$:
\[
  M_{i-1} \rightleftharpoons M_i \rightleftharpoons M_{i+1}.
\]

If the local rate equation for $S$-types is $\diff{s_i}{t} = f(s_i, m_i)$ then the full dynamics for patch $i$ in the strip is
\[
\begin{array}{rcl}
  \diff{s_i}{t} & = & f(s_i, m_i) \\
  \diff{m_i}{t} & = & -f(s_i, m_i) + \lambda (m_{i-1} - 2 m_i + m_{i+1}) \\
  \diff{n_i}{t} & = & \lambda (m_{i-1} - 2 m_i + m_{i+1}).
\end{array}
\]

Notice that if the distance between neighbouring patches is $\Delta$ so that patch $i$ is at position $x = \Delta i$, and $\Delta \rightarrow 0$ then
\[
  \pdiff{^2 m}{x} \approx \frac{1}{\Delta^2} (m_{i-1} - 2 m_i + m_{i+1})
\]
so, under these conditions the dynamics can be written as 
\[
\begin{array}{rcl}
  \pdiff{s}{t}(x) & = & f(s(x), m(x)) \\
  \pdiff{m}{t}(x) & = & -f(s(x), m(x)) + \lambda \Delta^2 \pdiff{^2 m}{x} \\
  \pdiff{n}{t}(x) & = & \lambda \Delta^2 \pdiff{^2 m}{x}.
\end{array}
\]

===== Hole models =====

In the hole models movement can only happen if there's a hole in the destination.  We need to take that into account.  The movement reactions (with rate constants $\lambda$) would be
\[
\begin{array}{lllll}
  M_{i-1} & + H_i     & \rightleftharpoons H_{i-1} & + M_i     \\
  M_i     & + H_{i+1} & \rightleftharpoons H_i     & + M_{i+1}.
\end{array}
\]

If the local rate equation for $S$-types is $\diff{s_i}{t} = f(s_i, m_i)$ then the full dynamics for patch $i$ in the strip is
\[
\begin{array}{rcl}
  \diff{s_i}{t} & = & f(s_i, m_i) \\
  \diff{m_i}{t} & = & -f(s_i, m_i) + \lambda ( (m_{i-1} + m_{i+1}) h_i - m_i (h_{i-1} + h_{i+1}) ) \\
  \diff{n_i}{t} & = & \lambda ( (m_{i-1} + m_{i+1}) h_i - m_i (h_{i-1} + h_{i+1}) ) \\
  \diff{h_i}{t} & = & -\diff{n_i}{t}.
\end{array}
\]

Notice that if the distance between neighbouring patches is $\Delta$ so that patch $i$ is at position $x = \Delta i$, and $\Delta \rightarrow 0$ then
\[
  h \pdiff{^2 m}{x} \approx \frac{1}{\Delta^2} h_i (m_{i-1} - 2 m_i + m_{i+1}) \\
  m \pdiff{^2 h}{x} \approx \frac{1}{\Delta^2} m_i (h_{i-1} - 2 h_i + h_{i+1})
\]
and
\[
  h \pdiff{^2 m}{x} - m \pdiff{^2 h}{x} \approx \frac{1}{\Delta^2} \left( h_i (m_{i-1} + m_{i+1}) - m_i (h_{i-1} + h_{i+1}) \right).
\]
So, under these conditions the dynamics can be written as 
\[
\begin{array}{rcl}
  \pdiff{s}{t}(x) & = & f(s(x), m(x)) \\
  \pdiff{m}{t}(x) & = & -f(s(x), m(x)) + \lambda \Delta^2 ( h \pdiff{^2 m}{x} - m \pdiff{^2 h}{x} )  \\
  \pdiff{n}{t}(x) & = & \lambda \Delta^2 ( h \pdiff{^2 m}{x} - m \pdiff{^2 h}{x} ).
\end{array}
\]




===== Fast reaction, slow diffusion limit =====

Already the spatial dynamics of the population $n(x)$ are more subtle than simply diffusive, depending on the behaviour of the mobile types.  The overall dynamics aren't tractable but we can make progress in some special cases:
  - If the diffusion processes are much faster than the local reactions then we may expect the mobile types to become homogenous.  Presumably, the overall population will also develop homogenously.
  - In the other extreme, the local reactions could be much faster than diffusion.  In this case we expect the frequency of mobile types at each position $m(x)/n(x)$ to reach a steady-state before $n(x)$ changes appreciably.

For example, from the table of $m/n$ above we find for Model 1 (neighbour avoiding)
\[
  \pdiff{n}{t} = \frac{\Delta ^2 \lambda  \sigma  \left(2 \rho ^2 \left(\pdiff{n}{x}\right)^2+n(x) (\rho +\sigma  n(x)) (2 \rho +\sigma  n(x)) \pdiff{^2 n}{x}\right)}{(\rho +\sigma  n(x))^3},
\]
Notice this equation is already more complicated than [[wp>reaction diffusion]] systems.




===== Equilibrium =====

In all four models, equilibrium is reached when $m$ has no curvature, so $m(x)=a x + b$ over some domain such that $0\leq m(x) \leq n(x)$.  We can use this information -- with our knowledge of the equilibrium frequency $m/n$ from above -- to determine $n(x)$ over the domain.  Interestingly, non-homogeneous equilibria are possible (with different choices of $a$ and $b$).  For example, for neighbour seeking (Model 2) the equilibrium density is
\[
  n(x) = \frac{\rho m(x)}{\rho - \sigma m(x)} = \frac{\rho (ax+b)}{\rho - \sigma (ax+b)}.
\]

I won't check but I expect the non-homogeneous equilibria are unstable.



===== Stability of the homogeneous equilibrium =====

Intuitively, expect the homogeneous solution to be stable for models 1 and 4 (neighbour avoiding and hole seeking) and unstable for 2 and 3 (neighbour seeking and hole avoiding).  To check, we begin by linearizing around the homogeneous equilibrium $(m_0,n_0)$,
\[
\begin{array}{rcl}
  m(x,t) & = & m_0 + u(x,t) \\
  n(x,t) & = & n_0 + v(x,t).
\end{array}
\]
	
If the local dynamics follow $\pdiff{s}{t} = f(m,n; k)$ then
\[
\begin{array}{rcl}
  \pdiff{m}{t} = -f(m,n; k) + \lambda \Delta^2 \pdiff{^2 m}{x} \\
  \pdiff{n}{t} = \lambda \Delta^2 \pdiff{^2 m}{x}.
\end{array}
\]
Linearizing gives a system of equations, $\pdiff{\mathbf{u}}{t} = \mathbf{A} \mathbf{u}$ where $\mathbf{u} = \left(\begin{matrix}u\\ v\end{matrix}\right)$.